//
//  huiyuanDetailsViewController.m
//  daogouApp
//
//  Created by panquanReabam.com on 15-6-2.
//  Copyright (c) 2015年 jiezsoft.com. All rights reserved.
//

#import "BusinessSupplierDetailViewController.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "HAODEsingleton.h"
#import "ProductView.h"
#import "UIViewExt.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "orderListCell.h"
#import "OrderDetailViewController.H"
#import "ServiceDetailViewController.H"
#import "RefundDetailViewController.H"
#import "BusinessMemberfindIntegralListViewController.h"
#import "BusinessMemberAddressViewController.h"
#import "BusinessCouponDetailViewController.h"
#import "BusinessActDetailViewController.h"
#import "ACETelPrompt.h"
#import <MapKit/MapKit.h>
#import "MapViewControllers.h"
#import "UMSocial.h"
#import "BusinessSupplierAddSupplierViewController.h"
@interface BusinessSupplierDetailViewController ()<MBProgressHUDDelegate,UIAlertViewDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate>
@property (strong, nonatomic) UIScrollView * scrollView;
@end

@implementation BusinessSupplierDetailViewController


{   UIView*beizhuView;
    UILabel *line;
    UIScrollView*myscrollView;
    HAODEsingleton* commdity;
    UIImageView* imageview;
    UILabel *lineLabel1;
    ProductView *clothView;
    NSMutableArray*Memo;
    NSMutableArray*Integral;
    NSMutableArray*Amount;
    NSMutableArray*CreateDate;
    float lastContentOffset;
    UILabel *lineLabel111;
    UIButton*agreementBtn;
    UIButton*agreementBtn1;
    BOOL saveAccount;
    BOOL saveAccount1;
    UIView*view11;
    UIView*view;
    UIButton*xiaButton;
    UILabel*address1;
    
    NSMutableArray*createDate;
    NSMutableArray*createName;
    NSMutableArray*ids;
    NSMutableArray*itemTypes;
    NSMutableArray*no;
    NSMutableArray*noType;
    
    NSMutableArray*status;
    NSMutableArray*statusName;
    NSMutableArray*totalMoney;
    NSMutableArray*totalQuantity;
    NSMutableArray*whsName;
   
    UITableView *table_list;
    UITableView *table_list1;
    UITableView *table_list2;
    UITableView *table_detailList;
    UIButton* bu;
    UIButton* bu1;
    UIButton* bu2;
    
    
}
@synthesize alt = alt;
-(void)BackAction:(UIButton *)sender{
    
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
       UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    self.title = @"供应商详情";
    
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     backColor,
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
    UIButton*editor = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0, 20, 20)];
    [editor setImage:[UIImage imageNamed:@"_0000_xingxifankui.png"] forState:UIControlStateNormal];
    [editor addTarget:self action:@selector(editor:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:editor];
    self.navigationItem.rightBarButtonItem = myBtnBtn;
    
    
    commdity = [HAODEsingleton shared];
    
    if ([commdity.gengxin isEqualToString:@""]) {
        
        [myscrollView removeFromSuperview];
        [self.customTabBar removeFromSuperview];
        [self.scrollView removeFromSuperview];
        
        [self gengxin];
        commdity.gengxin=@"123";
    }else{
        
        
        
    }
    
    
}

-(void)gengxin{
    
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    
    
    
    [param setValue:commdity.supplierId forKey:@"supplierId"];
    
    
    NSLog(@"====%@",param);
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    [HttpRequest requestData:@"Business/Supplier/Detail" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"33333333====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                NSMutableArray* arrr=[[NSMutableArray alloc]init];
       
               
                arrr=[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"tags"];
                NSMutableArray* Codearrr=[[NSMutableArray alloc]init];
                NSMutableArray* Namearrr=[[NSMutableArray alloc]init];
                for (NSDictionary* dicc in arrr )
                {
                    [Codearrr addObject:[dicc valueForKey:@"code"]];
                    [Namearrr addObject:[dicc valueForKey:@"content"]];
                    
                    
                }
                
                commdity.selectTagNameArray=[Namearrr copy];
                commdity.selectTagCodeArray=[Codearrr copy];
                commdity.Memo=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"remark"];
                commdity.memberId=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"supplierId"];
                commdity.DataLine=[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"tags"];
                
                commdity.ProvinceName=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"provinceName"];
                commdity.CityName=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"cityName"];
                commdity.RegionName=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"regionName"];
                commdity.adresssss=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"address"];
                
                commdity.Phone=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"phone"];
               
                 commdity.createName=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"linkMan"];
                commdity.userName=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"supName"];
               
                commdity.Sex=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"sex"];
             
                commdity.isActive=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"isActive"];
                
                myscrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, ScreenWidth, ScreenHeight)];
                [myscrollView setBackgroundColor: [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]];
                
                myscrollView.delegate = self;
                myscrollView.userInteractionEnabled = YES;
                myscrollView.scrollEnabled = YES;
                myscrollView.showsVerticalScrollIndicator = FALSE;
                myscrollView.showsHorizontalScrollIndicator = FALSE;
                
                NSString *s2 =[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"supName"];
                UIFont *font2 = [UIFont systemFontOfSize:17];
                CGSize size2 = CGSizeMake(ScreenWidth-60, 2000);
                CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];
                
                UILabel*name=[[UILabel alloc]initWithFrame:CGRectMake(15, 25, labelsize2.width, 17)];
                name.text= [[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"supName"];
                name.font= [UIFont systemFontOfSize:17];
                [name setTextColor:[UIColor blackColor]];
                [myscrollView addSubview:name];
               
                
                UILabel*isActive=[[UILabel alloc]initWithFrame:CGRectMake(name.right+5, 26, 35, 15)];
                
                if ([[NSString stringWithFormat:@"%@",  [[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"isActive"]]isEqualToString:@"0"]) {
                   
                    
                    
                    
                    isActive.text=@"不可用";
                     isActive.backgroundColor=zhonghuiColor;
                }else{
//                    isActive.backgroundColor=luseColor;
//                   isActive.text=@"可用";
                }
               
                isActive.font= [UIFont systemFontOfSize:11];
                isActive.textAlignment=NSTextAlignmentCenter;
                [isActive setTextColor:[UIColor whiteColor]];
                [myscrollView addSubview:isActive];
             
                
                UILabel*daogou=[[UILabel alloc]initWithFrame:CGRectMake(15,  57.5,30, contenfot)];
                daogou.text=@"员工";
                daogou.font= [UIFont systemFontOfSize:contenfot];
                [daogou setTextColor:zhonghuiColor];
                [myscrollView addSubview:daogou];
                NSString *s121 =[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"createName"];
                UIFont *font121 = [UIFont systemFontOfSize:contenfot];
                CGSize size121 = CGSizeMake(ScreenWidth-60, 2000);
                CGSize labelsize121 = [s121 sizeWithFont:font121 constrainedToSize:size121 lineBreakMode:NSLineBreakByCharWrapping];
                UILabel*daogou1=[[UILabel alloc]initWithFrame:CGRectMake(daogou.right, 57.5,labelsize121.width, contenfot)];
                daogou1.text=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"createName"];
                daogou1.font= [UIFont systemFontOfSize:contenfot];
                [daogou1 setTextColor:shenhuicolor];
                [myscrollView addSubview:daogou1];
                UILabel*mendian=[[UILabel alloc]initWithFrame:CGRectMake(daogou1.right+10, 57.5, 55, contenfot)];
                mendian.text=@"登记日期";
                mendian.font= [UIFont systemFontOfSize:contenfot];
                [mendian setTextColor:zhonghuiColor];
                [myscrollView addSubview:mendian];
                
                NSRange range={0,10};
                NSString* string =[[NSString stringWithFormat:@"%@",[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"createDate"]] substringWithRange:range];
                UILabel*mendian1=[[UILabel alloc]initWithFrame:CGRectMake(mendian.right, 57.5, 200, contenfot)];
                mendian1.text=string;
                mendian1.font= [UIFont systemFontOfSize:contenfot];
                [mendian1 setTextColor:shenhuicolor];
                [myscrollView addSubview:mendian1];
                
                
                
                
                UILabel*lianxiren=[[UILabel alloc]initWithFrame:CGRectMake(15, 75,45, contenfot)];
                lianxiren.text=@"联系人";
                lianxiren.font= [UIFont systemFontOfSize:contenfot];
                [lianxiren setTextColor:zhonghuiColor];
                [myscrollView addSubview:lianxiren];
                NSString *s =[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"linkMan"];
                UIFont *font = [UIFont systemFontOfSize:contenfot];
                CGSize size = CGSizeMake(ScreenWidth-60, 2000);
                CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
                UILabel*lianxiren1=[[UILabel alloc]initWithFrame:CGRectMake(lianxiren.right, 75,labelsize.width+5, contenfot)];
                lianxiren1.text=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"linkMan"];
                lianxiren1.font= [UIFont systemFontOfSize:contenfot];
                [lianxiren1 setTextColor:shenhuicolor];
                [myscrollView addSubview:lianxiren1];
               
                UILabel*lianxirendianhua=[[UILabel alloc]initWithFrame:CGRectMake(lianxiren1.right+10, 75, 55, contenfot)];
                lianxirendianhua.text=@"电话咨询";
                lianxirendianhua.font= [UIFont systemFontOfSize:contenfot];
                [lianxirendianhua setTextColor:zhonghuiColor];
                [myscrollView addSubview:lianxirendianhua];
                UILabel*lianxirendianhua1=[[UILabel alloc]initWithFrame:CGRectMake(lianxirendianhua.right, 75, 200, contenfot)];
                lianxirendianhua1.text=[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"phone"];
                lianxirendianhua1.font= [UIFont systemFontOfSize:contenfot];
                [lianxirendianhua1 setTextColor:shenhuicolor];
                [myscrollView addSubview:lianxirendianhua1];

                
                
                
                NSString *s1 = [NSString stringWithFormat:@"地址  %@%@%@%@",[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"provinceName"],[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"cityName"],[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"regionName"],[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"address"]];
                
                commdity.adress=[NSString stringWithFormat:@"%@",[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"address"]];
                
                UIFont *font1 = [UIFont systemFontOfSize:contenfot];
                CGSize size1 = CGSizeMake(ScreenWidth-100, 2000);
                CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
                address1=[[UILabel alloc]initWithFrame:CGRectMake(15,90, ScreenWidth-30, labelsize1.height)];
                address1.text=s1 ;
                address1.numberOfLines=0;
                address1.font= [UIFont systemFontOfSize:contenfot];
                [address1 setTextColor:shenhuicolor];
                
                [myscrollView addSubview:address1];
                
                
                
                UIButton*telImage1 = [[UIButton alloc]init];
                telImage1.frame = CGRectMake(50,address1.bottom+10+15,20, 20);
                [telImage1 setImage:[UIImage imageNamed:@"dianhuasss"] forState:UIControlStateNormal];
                [myscrollView addSubview:telImage1];
                UILabel*tel1=[[UILabel alloc]initWithFrame:CGRectMake(60, address1.bottom+10, ScreenWidth/2-70, 50)];
                tel1.text=[NSString stringWithFormat:@"%@", @"电话咨询"];
                tel1.textColor=shenhuicolor;
                tel1.numberOfLines=0;
                tel1.textAlignment=NSTextAlignmentCenter;
                tel1.font=[UIFont systemFontOfSize:15];
                [myscrollView addSubview:tel1];
                UIButton*jiantouBtnjiada = [[UIButton alloc]init];
                jiantouBtnjiada.frame = CGRectMake(0,address1.bottom+10,ScreenWidth/2, 50);
                [jiantouBtnjiada addTarget:self action:@selector(shanghubuttonimage:) forControlEvents:UIControlEventTouchUpInside];
                jiantouBtnjiada.tag=301;
                [myscrollView addSubview:jiantouBtnjiada];
                
                
                UILabel*line1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2, address1.bottom+15, 0.35, 30)];
                line1.backgroundColor=qianhuicolor;
                [myscrollView addSubview:line1];
                
                
                UIButton*addressImage = [[UIButton alloc]init];
                addressImage.frame = CGRectMake(ScreenWidth/2+40,address1.bottom+10+15,20, 20);
                [addressImage setImage:[UIImage imageNamed:@"daohangsss"] forState:UIControlStateNormal];
                [myscrollView addSubview:addressImage];
                UILabel*address=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2, address1.bottom+10, ScreenWidth/2, 50)];
                address.text=[NSString stringWithFormat:@"%@", @"    去那里"];
                address.textColor=shenhuicolor;
                address.textAlignment=NSTextAlignmentCenter;
                address.font=[UIFont systemFontOfSize:15];
                [myscrollView addSubview:address];
                UIButton*jiantouBtnjiada1 = [[UIButton alloc]init];
                jiantouBtnjiada1.frame = CGRectMake(ScreenWidth/2,address1.bottom+10,ScreenWidth/2, 50);
                [jiantouBtnjiada1 addTarget:self action:@selector(shanghubuttonimage:) forControlEvents:UIControlEventTouchUpInside];
                jiantouBtnjiada1.tag=302;
                [myscrollView addSubview:jiantouBtnjiada1];

                
                
                
                
                
                xiaButton= [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth/2-15,address1.bottom+40,30,30)];
                [xiaButton setBackgroundImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
                xiaButton.titleLabel.font=[UIFont systemFontOfSize:13];
                [xiaButton addTarget:self action:@selector(zankai:) forControlEvents:UIControlEventTouchUpInside];
                [myscrollView addSubview:xiaButton];
                
                
                view=[[UIView alloc]initWithFrame:CGRectMake(0, xiaButton.bottom+5, ScreenWidth, 250/2)];
                view.backgroundColor=[UIColor whiteColor];
                [myscrollView addSubview:view];
                
                UIImageView *_xianview11 = [[UIImageView alloc]initWithFrame:CGRectMake(15,0, ScreenWidth-30, 0.5)];
                _xianview11.image=[UIImage imageNamed:@"hengxian"];
                [view addSubview:_xianview11];

                
                
                
                if (arrr.count>0) {
                    
                    for (int i = 0,j = 0; i < arrr.count; i++) {
                        if (i % 4 == 0) {
                            j++;
                        }
                        
                        clothView = [[ProductView alloc]initWithFrame:CGRectMake(12.5+(ScreenWidth/4-5)*(i%4), 10+(40*(j-1)), ScreenWidth/4-15, 26)];
                        clothView.buttonView.titleLabel.textAlignment=NSTextAlignmentCenter;
                        clothView.buttonView.titleLabel.font=[UIFont systemFontOfSize:contenfot];
                        [clothView.buttonView setTitle: [[arrr objectAtIndex:i] objectForKey:@"content"] forState:UIControlStateNormal];
                        clothView.buttonView.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:234/255.0 alpha:1];
                        clothView.buttonView.tag=[[[arrr objectAtIndex:i] objectForKey:@"code"] intValue];
                        [clothView.buttonView setTitleColor:huangtitleColor forState:0];
                        [clothView.buttonView.layer setCornerRadius:13.0];
                        [clothView.buttonView.layer setBorderWidth:0.43];
                        [clothView.buttonView.layer setMasksToBounds:YES];
                        CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                        CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){209/255.0,170/255.0, 56/255.0, 1.0   });
                        [clothView.buttonView.layer setBorderColor:colorref2];//边框颜色
                        
                        [view addSubview:clothView];
                        
                        
                    }
                    
                    
                }else {
                    
                    
                    
                }
                
                
//                commdity.Memo=[NSString stringWithFormat:@"%@",[dic objectForKey:@"memo"]];
                
            commdity.Memo=[NSString stringWithFormat:@"%@",[[[severDataDict.dataDict objectForKey:@"DataLine"] objectForKey:@"supplier"]objectForKey:@"remark"]];
                
                beizhuView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 90)];
                
                
                
                
                UIImageView *_xianview1 = [[UIImageView alloc]initWithFrame:CGRectMake(15,5, ScreenWidth-30, 0.5)];
                _xianview1.image=[UIImage imageNamed:@"hengxian"];
                [beizhuView addSubview:_xianview1];
                UILabel*beizhu=[[UILabel alloc]initWithFrame:CGRectMake(15, 5, 30, 40)];
                beizhu.text=@"备注";
                beizhu.font= [UIFont systemFontOfSize:contenfot];
                [beizhu setTextColor:[UIColor blackColor]];
                [beizhuView addSubview:beizhu];
                
                if ([commdity.Memo length]>1) {
                    
                    
                    NSString *s1 =[NSString stringWithFormat:@"%@", commdity.Memo];
                    UIFont *font1 = [UIFont systemFontOfSize:contenfot];
                    CGSize size1 = CGSizeMake(ScreenWidth-60, 2000);
                    CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
                    
                    UILabel*beizhu1=[[UILabel alloc]initWithFrame:CGRectMake(15, beizhu.bottom+2, ScreenWidth-40, labelsize1.height+30)];
                    beizhu1.text=s1;
                    beizhu1.numberOfLines=0;
                    beizhu1.font= [UIFont systemFontOfSize:contenfot];
                    [beizhu1 setTextColor:shenhuicolor];
                    [beizhuView addSubview:beizhu1];
                    
                    if (arrr.count>0) {
                        beizhuView.frame=CGRectMake(0, clothView.bottom+10, ScreenWidth, beizhu1.bottom);
                    }else{
                        
                        beizhuView.frame=CGRectMake(0, 30, ScreenWidth,  beizhu1.bottom);
                        
                    }
                    
                    
                    
                }else{
                    NSString *s1 =[NSString stringWithFormat:@"%@", @"无"];
                    UIFont *font1 = [UIFont systemFontOfSize:contenfot];
                    CGSize size1 = CGSizeMake(ScreenWidth-60, 2000);
                    CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
                    
                    UILabel*beizhu1=[[UILabel alloc]initWithFrame:CGRectMake(15, beizhu.bottom-5, ScreenWidth-40, labelsize1.height+30)];
                    beizhu1.text=s1;
                    beizhu1.numberOfLines=0;
                    beizhu1.font= [UIFont systemFontOfSize:contenfot];
                    [beizhu1 setTextColor:shenhuicolor];
                    [beizhuView addSubview:beizhu1];
                    
                    if (arrr.count>0) {
                        beizhuView.frame=CGRectMake(0, clothView.bottom+10, ScreenWidth, beizhu1.bottom);
                    }else{
                        
                        beizhuView.frame=CGRectMake(0, 30, ScreenWidth, beizhu1.bottom);
                        
                    }
                    
                    
                    
                }
                
                [view addSubview:beizhuView];
                
                
                
                
                view.frame=CGRectMake(0, xiaButton.bottom+5, ScreenWidth,beizhuView.bottom);
                
          
                myscrollView.frame=CGRectMake(0, 64, ScreenWidth, xiaButton.bottom);
                [myscrollView setContentSize:CGSizeMake(ScreenWidth, xiaButton.bottom)];
                
                [self .view addSubview:myscrollView];
               
           
               
                [self liebiaoshuju];
                
             
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:requestResultStr delegate:self cancelButtonTitle:@"确定返回" otherButtonTitles: nil];
                [alert show];
                
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
}
- (void)shanghubuttonimage:(UIButton *)button{
    if (button.tag==301) {
        
        
        
        [ACETelPrompt callPhoneNumber: commdity.Phone
                                 call:^(NSTimeInterval duration) {
                                     NSLog(@"User made a call of %.1f seconds", duration);
                                     
                                 } cancel:^{
                                     NSLog(@"User cancelled the call");
                                 }];
        
        
        
        
        
    }
    if (button.tag==302) {
        
        
        [self address];
        
        
        
    }
    
    if (button.tag==303) {

        
    }
    
}

-(void)address{
    
    
    NSString *oreillyAddress =[NSString stringWithFormat:@"%@%@%@",   commdity.ProvinceName,  commdity.CityName, commdity.adress];
    
    CLGeocoder *myGeocoder = [[CLGeocoder alloc] init];
    [myGeocoder geocodeAddressString:oreillyAddress completionHandler:^(NSArray *placemarks, NSError *error) {
        if ([placemarks count] > 0 && error == nil) {
            
            CLPlacemark *firstPlacemark = [placemarks objectAtIndex:0];
            double latitude=firstPlacemark.location.coordinate.longitude;
            NSString *latitudeString=[NSString stringWithFormat:@"%f",latitude];
            double longitude=firstPlacemark.location.coordinate.latitude;
            NSString *longitudeString=[NSString stringWithFormat:@"%f",longitude];
            NSLog(@"latitudeString= %@", longitudeString);
            NSLog(@"longitudeString= %@",latitudeString);
            NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                        oreillyAddress,@"address",
                                        oreillyAddress,@"city",
                                        @"google",@"from_map_type",
                                        oreillyAddress,@"region", nil];
            
            [dic setValue:longitudeString forKey:@"google_lat"];
            [dic setValue:latitudeString forKey:@"google_lng"];
            
            NSLog(@"latitudeString= %@", longitudeString);
            NSLog(@"longitudeString= %@",latitudeString);
            
            
            MapViewControllers* h=[[MapViewControllers alloc] init];
            h.navDic=dic;
            h.mapType = RegionNavi;
            [self.navigationController pushViewController:h animated:YES];
            
            
            
        }
        else if ([placemarks count] == 0 && error == nil) {
            NSLog(@"Found no placemarks.");
        }
        else if (error != nil) {
            NSLog(@"An error occurred = %@", error); }
    }];
    
    
    
}
-(void)zankai:(UIButton*)sender{
    
    self.s=@"you";
    
    [xiaButton removeFromSuperview];
    view.frame=CGRectMake(0, address1.bottom+70, ScreenWidth,beizhuView.bottom);
    myscrollView.frame=CGRectMake(0, 64, ScreenWidth, view.bottom);
    [myscrollView setContentSize:CGSizeMake(ScreenWidth, view.bottom)];
    [self.customTabBar removeFromSuperview];
    [self.scrollView removeFromSuperview];

    [self liebiaoshuju];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if ([self.s isEqualToString:@"you"]) {
        CGFloat offset=scrollView.contentOffset.y;
        if (offset>100) {
            
            xiaButton= [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth/2-15,address1.bottom+40,30,30)];
            [xiaButton setBackgroundImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
            xiaButton.titleLabel.font=[UIFont systemFontOfSize:13];
            [xiaButton addTarget:self action:@selector(zankai:) forControlEvents:UIControlEventTouchUpInside];
            [myscrollView addSubview:xiaButton];
            
            view.frame=CGRectMake(0, xiaButton.bottom+5, ScreenWidth,beizhuView.bottom);
            myscrollView.frame=CGRectMake(0, 64, ScreenWidth, xiaButton.bottom);
            [myscrollView setContentSize:CGSizeMake(ScreenWidth, xiaButton.bottom)];
            [self.customTabBar removeFromSuperview];
            [self.scrollView removeFromSuperview];
           
            [self liebiaoshuju];
            NSLog(@"shang");
            self.s=@"";
        }else {
            
            
            
            
        }
        
    }else{
        
        
        
    }
}
-(void)liebiaoshuju{
    [table_list removeFromSuperview];
    table_list = [[UITableView alloc]initWithFrame:CGRectMake(0, myscrollView.bottom, ScreenWidth, ScreenHeight-myscrollView.bottom) style:UITableViewStylePlain];
    table_list.delegate = self;
    table_list.dataSource = self;
    table_list.rowHeight = 60;
    table_list.separatorStyle=UITableViewCellSeparatorStyleNone;
    
    [self .view addSubview:table_list];
    
    UIView* vi=[[UIView alloc]initWithFrame:CGRectMake(0,0, ScreenWidth, 55)];
    vi.backgroundColor=[UIColor whiteColor];
    [myscrollView addSubview:vi];
    UIView* disetu=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
    disetu.backgroundColor=zuiqianhuicolor;
    disetu.layer.borderWidth = 0.35;
    disetu.layer.borderColor = qianhuicolor.CGColor;
    [vi addSubview:disetu];
    
    
    UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, disetu.bottom+10, 80, 45)];
    shangpingxinxi.text=@"往来明细";
    shangpingxinxi.textColor=[UIColor blackColor];
    shangpingxinxi.font=[UIFont systemFontOfSize:sixteenORfifteenFot];
    [vi addSubview:shangpingxinxi];
    
    UIImageView *_xianview11 = [[UIImageView alloc]initWithFrame:CGRectMake(15,shangpingxinxi.bottom, ScreenWidth-30, 0.5)];
    _xianview11.image=[UIImage imageNamed:@"hengxian"];
    [vi addSubview:_xianview11];


    table_list.tableHeaderView=vi;
    
    createDate= [[NSMutableArray alloc] init];
    createName= [[NSMutableArray alloc] init];
    ids= [[NSMutableArray alloc] init];
    no= [[NSMutableArray alloc] init];
    noType= [[NSMutableArray alloc] init];
    status= [[NSMutableArray alloc] init];
    statusName= [[NSMutableArray alloc] init];
    totalMoney= [[NSMutableArray alloc] init];
    totalQuantity= [[NSMutableArray alloc] init];
    whsName= [[NSMutableArray alloc] init];
    itemTypes= [[NSMutableArray alloc] init];
    
    
    
    
    
    NSUserDefaults *user12 = [NSUserDefaults standardUserDefaults];
    NSString* Token12 = [user12 objectForKey:@"tokenId"];
    
    NSMutableDictionary *param12 = [NSMutableDictionary new];
    [param12 setValue:Token12 forKey:@"tokenId"];
    [param12 setValue:commdity.supplierId forKey:@"supplierId"];
    
    
    NSLog(@"====%@",param12);
    
    [HttpRequest requestData:@"Business/Supplier/SupplierTradeList" params:param12 success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                NSMutableArray* arrr=[[NSMutableArray alloc]init];
                
                arrr=[severDataDict.dataDict objectForKey:@"DataLine"];
                
                
                if (arrr.count>0) {
                    
                    
                    
                    
                    for (NSDictionary* dicc in arrr )
                    {
                        [totalQuantity addObject:[dicc valueForKey:@"totalQuantity"]];
                        [whsName addObject:[dicc valueForKey:@"whsName"]];
                        [totalMoney addObject:[dicc valueForKey:@"totalMoney"]];
                     
                        [ids addObject:[dicc valueForKey:@"id"]];
                        [createDate addObject:[dicc valueForKey:@"createDate"]];
                        [no addObject:[dicc valueForKey:@"no"]];
                        [createName addObject:[dicc valueForKey:@"createName"]];
                        [noType addObject:[dicc valueForKey:@"noType"]];
                         [itemTypes addObject:[dicc valueForKey:@"itemTypes"]];
                         [status addObject:[dicc valueForKey:@"status"]];
                        
                    }
                    
                    
                }
                [table_list reloadData];
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                // [Global showTextHud:requestResultStr view:self.view];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
   
    
    
   
   
    
}



- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if (buttonIndex == 0) {
        
        [self.navigationController popViewControllerAnimated:YES];
        
    }
    
}



//上拉刷新
- (void)addFooter
{
    
    
    
}
- (void)doneWithView:(MJRefreshBaseView *)refreshView
{
    [_table reloadData];
    [refreshView endRefreshing];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return [no count];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    orderListCell* cell = (orderListCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"orderListCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    UIButton*jiantou = [[UIButton alloc]init];
    jiantou.frame = CGRectMake(0,0, 8, 13);
    [jiantou setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
    
    //    cell.accessoryView = jiantou;
   
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        NSString *s21 = [NSString stringWithFormat:@"%@",  [no objectAtIndex:indexPath.row]];
        UIFont *font21 = [UIFont systemFontOfSize:titleNamefot];
        CGSize size21 = CGSizeMake(320, 2000);
        CGSize labelsize21 = [s21 sizeWithFont:font21 constrainedToSize:size21 lineBreakMode:NSLineBreakByCharWrapping];
        cell.DocNum.text =[NSString stringWithFormat:@"%@ ",  s21];
        cell.DocNum.textColor=[UIColor blackColor];
        cell.DocNum.frame=CGRectMake(15, 20, labelsize21.width+5,titleNamefot);
        cell.DocNum.font= [UIFont fontWithName:@"Arial" size:titleNamefot];
        
        //直接收款
        
     
            
            cell.Reasons.frame=CGRectMake(cell.DocNum.right-1,  20, 55, contenfot);
            
            cell.Reasons.font=[UIFont systemFontOfSize:contenfot];
//            cell.Reasons.textAlignment=NSTextAlignmentCenter;
            if ([[status objectAtIndex:indexPath.row] isEqualToString:@"N"]) {
                cell.Reasons.textColor=hongsecolor;
                cell.Reasons.text=[NSString stringWithFormat:@"%@",  @"未清"];
            }if ([[status objectAtIndex:indexPath.row] isEqualToString:@"Y"]) {
                cell.Reasons.textColor=luseColor;
                cell.Reasons.text=[NSString stringWithFormat:@"%@",  @"已清"];
            }
            if ([[status objectAtIndex:indexPath.row] isEqualToString:@"C"]) {
                cell.Reasons.textColor=luseColor;
                cell.Reasons.text=[NSString stringWithFormat:@"%@",  @"已取消"];
            }
        
    cell.GuideCode.text=[NSString stringWithFormat:@"%@", @"员工"];
    cell.GuideCode.font=[UIFont systemFontOfSize:contenfot];
    cell.GuideCode.textColor=zhonghuiColor;
    
    cell.GuideCode.frame=CGRectMake(15,  50,  30, contenfot);
    
    
    
    NSString *s111 = [NSString stringWithFormat:@"%@", [createName objectAtIndex:indexPath.row]];
    UIFont *font111 = [UIFont systemFontOfSize:contenfot];
    CGSize size111 = CGSizeMake(320, 2000);
    CGSize labelsize111= [s111 sizeWithFont:font111 constrainedToSize:size111 lineBreakMode:NSLineBreakByCharWrapping];
    cell.GuideCode1.text=[NSString stringWithFormat:@"%@", [createName objectAtIndex:indexPath.row]];
    cell.GuideCode1.font=[UIFont systemFontOfSize:contenfot];
    cell.GuideCode1.textColor=shenhuicolor;
    cell.GuideCode1.frame=CGRectMake(cell.GuideCode.right,   50,  labelsize111.width+15, contenfot);
    
    
    
    
    
    
    cell.MemberCode.text=[NSString stringWithFormat:@"%@", @"日期"];
    cell.MemberCode.font=[UIFont systemFontOfSize:contenfot];
    cell.MemberCode.textColor=zhonghuiColor;
    cell.MemberCode.frame=CGRectMake(cell.GuideCode1.right,  50,  30, contenfot);
    
    NSRange range={0,10};
    NSString* string =[[createDate objectAtIndex:indexPath.row] substringWithRange:range];
    
    
    cell.MemberCode1.text=[NSString stringWithFormat:@"%@", string];
    
    cell.MemberCode1.font=[UIFont systemFontOfSize:contenfot];
    cell.MemberCode1.textColor=shenhuicolor;
    cell.MemberCode1.frame=CGRectMake(cell.MemberCode.right, 50,  200*ScreenWidth/750, contenfot);
    
    
    NSString *s11 = [NSString stringWithFormat:@"%@", [noType objectAtIndex:indexPath.row]];
    UIFont *font11 = [UIFont systemFontOfSize:contenfot];
    CGSize size11 = CGSizeMake(320, 2000);
    CGSize labelsize11= [s11 sizeWithFont:font11 constrainedToSize:size11 lineBreakMode:NSLineBreakByCharWrapping];
    
    cell.ItemName.text=[NSString stringWithFormat:@"%@", [noType objectAtIndex:indexPath.row]];
    cell.ItemName.font=[UIFont systemFontOfSize:contenfot];
    cell.ItemName.textColor=zhonghuiColor;
    cell.ItemName.frame=CGRectMake(15,   70,  labelsize11.width+5, contenfot);
    
    
    
    NSString *s1 = [NSString stringWithFormat:@"%@ %@件", [itemTypes objectAtIndex:indexPath.row], [totalQuantity objectAtIndex:indexPath.row]];
    UIFont *font1 = [UIFont systemFontOfSize:contenfot];
    CGSize size1 = CGSizeMake(320, 2000);
    CGSize labelsize1= [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];

    
    cell.ItemName1.text=[NSString stringWithFormat:@"%@ 共%@件", [itemTypes objectAtIndex:indexPath.row], [totalQuantity objectAtIndex:indexPath.row]];
    cell.ItemName1.font=[UIFont systemFontOfSize:contenfot];
    cell.ItemName1.textColor=shenhuicolor;
    cell.ItemName1.frame=CGRectMake(cell.ItemName.right, 70, labelsize1.width+15, contenfot);
        
   
        
        
        
        cell.DocTotal.text=[NSString stringWithFormat:@"%@", @"金额"];
        cell.DocTotal.font=[UIFont systemFontOfSize:contenfot];
        cell.DocTotal.textColor=zhonghuiColor;
        cell.DocTotal.frame=CGRectMake(cell.ItemName1.right+5,   70,  30, contenfot);
        
        
        NSString*GoldPrice=[NSString stringWithFormat:@"%@",[totalMoney objectAtIndex:indexPath.row]];
        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        [numberFormatter setPositiveFormat:@"###,##0.00;"];
        NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
        
        NSString *s = [NSString stringWithFormat:@"￥%@", formattedNumberString];
        UIFont *font = [UIFont systemFontOfSize:contenfot];
        CGSize size = CGSizeMake(320, 2000);
        CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
        
        cell.DocTotal1.text=[NSString stringWithFormat:@"￥%@", formattedNumberString];
        cell.DocTotal1.font=[UIFont systemFontOfSize:contenfot];
        cell.DocTotal1.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
        cell.DocTotal1.frame=CGRectMake(cell.DocTotal.right,  70, labelsize.width+3, contenfot);
        
        
        
        if (no.count !=indexPath.row+1) {
            UILabel *lineLabel21=[[UILabel alloc] initWithFrame:CGRectMake(15,105-0.35, ScreenWidth-30, 0.35)];
            lineLabel21.backgroundColor=qianhuicolor;
            [cell.contentView addSubview:lineLabel21];
            
        }
        
        if (no.count ==indexPath.row+1) {
            UILabel *lineLabel21=[[UILabel alloc] initWithFrame:CGRectMake(0, 105-0.35, ScreenWidth, 0.35)];
            lineLabel21.backgroundColor=qianhuicolor;
            [cell.contentView addSubview:lineLabel21];
            
        }
    
    
    
        return cell;
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return  105;
}
#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if (tableView == table_list) {
//        if ([[orderType objectAtIndex:indexPath.row] isEqualToString:@"order"]) {
//            
//            commdity.orderId=orderId[indexPath.row];
//            
//            commdity.orderStatus=orderStatus[indexPath.row];
//            commdity.deliveryStatus=deliveryStatus[indexPath.row];
//            commdity.installStatus=installStatus[indexPath.row];
//            OrderDetailViewController *detailViewController = [[OrderDetailViewController alloc] init];
//            [self.navigationController pushViewController:detailViewController animated:YES];
//            
//        }
//        
//        if ([[orderType objectAtIndex:indexPath.row] isEqualToString:@"service"]) {
//            commdity.orderId=orderId[indexPath.row];
//            ServiceDetailViewController *detailViewController = [[ServiceDetailViewController alloc] init];
//            [self.navigationController pushViewController:detailViewController animated:YES];
//            
//            
//            
//        }
//        if ([[orderType objectAtIndex:indexPath.row] isEqualToString:@"refund"]) {
//            commdity.orderId=orderId[indexPath.row];
//            RefundDetailViewController *detailViewController = [[RefundDetailViewController alloc] init];
//            [self.navigationController pushViewController:detailViewController animated:YES];
//            
//        }
   }
  
    
    }

#pragma mark - Table view delegate
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
    
    //     bugview.frame=CGRectMake(0, ScreenHeight, ScreenWidth, 50);
    
    //    if (lastContentOffset < scrollView.contentOffset.y) {
    //
    //        [[self rdv_tabBarController] setTabBarHidden:!self.rdv_tabBarController.tabBarHidden animated:NO];
    //
    //    }else{
    //
    //        [[self rdv_tabBarController] setTabBarHidden:!self.rdv_tabBarController.tabBarHidden animated:YES];
    //
    //    }
}

-(void)editor:(UIButton*)sender{
    
    BusinessSupplierAddSupplierViewController *detailViewController = [[BusinessSupplierAddSupplierViewController alloc] init];
    [self.navigationController pushViewController:detailViewController animated:YES];
    
    
    
}

- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
